package aqr;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class FizzBuzz {

	public static void main(String[] args) {
		int length=0;
		
		System.out.print("Enter the length: ");
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			length = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			System.out.println("Invalid format!");
		}
		
		System.out.println("FizzBuzz string for the length "+length+" is: ");
		for(int i=0; i< length; i++) {
			System.out.print(fizzBuzz(i+1)+" ");
		}
	}

	static String fizzBuzz(int i) {
		if (i%15 == 0)
			return "FizzBuzz";
		
		if(i%3==0)
			return "Fizz";
		
		if (i%5==0)
			return "Buzz";
		
		return String.valueOf(i);
	}

}
